package cluster.traversal;

import text.Text;
import text.TextSetManager;
import text.traversal.ITextTraversal;

public class ComputeWordReferenceCount implements ITextTraversal
{
	public final static String WORD_REFERENCE_COUNT = "WordReferenceCount";
	
	private final TextSetManager textSetManager;
	
	public ComputeWordReferenceCount(TextSetManager textSetManager)
	{
		this.textSetManager = textSetManager;
	}

	public void traversal(String word, Text text)
	{
		double count = 0;
		
		
		for(Text text2 : textSetManager.getTextList())
		{
			if(text2.getOccurenceCount(word) > 0)
			{
				count++;
			}
		}
		
		textSetManager.addInfo(ComputeWordReferenceCount.WORD_REFERENCE_COUNT, word, count);
	}
}
